/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Domain;

import Main.ObjectFileIO;
import java.io.File;
import java.util.HashMap;

/**
 *
 * @author Mattis
 */
public class GlobalHashMap {
    private static HashMap<String, State> hashmap = null;
    public static final String fileName = "HASHMAP.txt";
    
    public static HashMap<String, State> getHashMap(){
        // open file with the hashmap and return it
        if(hashmap != null){
            System.out.println("hashmap not null");
            return hashmap;
        }
        File file = new File(fileName);
        if(file.exists()){
            System.out.println("file exist");
            ObjectFileIO tempHash = new ObjectFileIO(fileName);
            hashmap = (HashMap) tempHash.readFile();
        } else{
            System.out.println("file does not exist");
            hashmap = new HashMap<String, State>();
        }
        return hashmap;
    }
    
    
    public static void saveHashMap(){
        ObjectFileIO file = new ObjectFileIO(fileName);
        file.saveFiles(hashmap);
    }
    
    
}
